#pragma once
#include <qobject.h>
#include <qstring.h>
#include <qmap.h>
#include <thread>
#include "common.h"

class ProcessMonitor : public QObject
{
	Q_OBJECT

public:
	struct Process {
		QString number;
		QString name;
		QString path;
		bool enableGuard{false};
		bool status{false};
	};

public:
	ProcessMonitor();
	~ProcessMonitor();

	void addProcess(Process proc);
	void clearProcesses();
	void setProcessGruardStatus(QString name, bool status);
	void setProcessStatus(QString name, bool status);

private:
	void run();
	bool IsProcessExist(QString processName);

	

signals:
	void signProcessStateChanged(ProcessMonitor::Process proc, bool status);

private:
	bool exit_;
	std::shared_ptr<std::thread> thread_;
	QMap<QString, Process> processes_;
};

